<div class="layui-form" lay-filter="layuiadmin-form-user" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="userName" value="{{ d.params.userName || '' }}" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                <input type="hidden" name="userId" value="{{ d.params.userId || '' }}" lay-verify="required" class="layui-input">
            </script>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户密码</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="password" name="userPwd" value="{{ d.params.userPwd || '' }}" lay-verify="required" placeholder="请输入用户密码" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">教师 ID</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="teacherId" value="{{ d.params.teacherId || '' }}" lay-verify="required|number" placeholder="请输入教师 ID" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">角色 ID</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="text" name="roleId" value="{{ d.params.roleId || '' }}" lay-verify="required|number" placeholder="请输入角色 ID" autocomplete="off" class="layui-input">
            </script>
        </div>
    </div>
    <div class="layui-form-item" lay-filter="userFlag">
        <label class="layui-form-label">用户状态</label>
        <div class="layui-input-inline">
            <script type="text/html" template>
                <input type="radio" name="userFlag" value="0" title="启用" {{ d.params.userFlag === '0' ? 'checked' : '' }}>
                <input type="radio" name="userFlag" value="1" title="禁用" {{ d.params.userFlag === '1' ? 'checked' : '' }}>
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="button" lay-submit lay-filter="LAY-user-modify" value="确认" class="layui-btn">
        </div>
    </div>
</div>

<script>
    layui.use(['admin', 'form'], function(){
        var $ = layui.$
            ,form = layui.form;

    });

    layui.use([ 'form', 'layer' ], function() {
        $ = layui.$;
        var form = layui.form, layer = layui.layer;

        // 监听提交
        form.on('submit(LAY-user-modify)', function(data) {
            var field = data.field;
            $.ajax({
                type: 'POST',
                url: '/updateUserServlet',
                data: field,
                success: function(data) {
                    if (data == "Ok") {
                        layer.alert("修改成功", {
                            icon: 6
                        });
                    } else {
                        layer.alert(data, {
                            title: '修改失败'
                        });
                    }
                }
            });
            return false;
        });
    });
</script>